<template>
  <span
    class="f-tag-info"
    :class="{
      'is-no-label': !label,
      [`f-tag-info--${type}`]: true,
      'is-checkable': checkable,
      'is-checked': checked
    }"
  >
    <span v-if="label" class="f-tag-info__label">{{ label }}</span>
    <span class="f-tag-info__value">{{ value }}</span>
    <span class="f-tag-info__check">
      <i class="el-icon-check"></i>
    </span>
  </span>
</template>

<script>
export default {
  props: {
    label: String,
    type: {
      type: String,
      default: 'default'
    },
    value: {
      type: String,
      required: true
    },
    checkable: {
      type: Boolean,
      default: false
    },
    checked: {
      type: Boolean,
      default: false
    }
  }
}
</script>

<style lang="less" scoped>
@import '~assets/main.less';
.f-tag-info {
  display: inline-block;
  & + .f-tag-info {
    margin: 0 0 0 5px;
  }
  .f-tag-info__label,
  .f-tag-info__value {
    display: inline-block;
    font-size: 12px;
    line-height: 1;
    padding: 5px 8px;
    margin: 0;
  }
  .f-tag-info__label {
    display: inline-block;
    border-radius: 4px 0 0 4px;
  }
  .f-tag-info__value {
    display: inline-block;
    border-radius: 0 4px 4px 0;
  }
  &.is-no-label {
    .f-tag-info__value {
      border-radius: 4px;
    }
  }

  &.f-tag-info--default {
    span {
      color: #fff;
    }
    .f-tag-info__label {
      background: #555;
    }
    .f-tag-info__value {
      background: @c;
    }
  }

  &.f-tag-info--success {
    span {
      color: #fff;
    }
    .f-tag-info__label {
      background: #555;
    }
    .f-tag-info__value {
      background: @c-success;
    }
  }

  &.f-tag-info--danger {
    span {
      color: #fff;
    }
    .f-tag-info__label {
      background: #555;
    }
    .f-tag-info__value {
      background: @c-err;
    }
  }

  &.f-tag-info--warn {
    span {
      color: #fff;
    }
    .f-tag-info__label {
      background: #555;
    }
    .f-tag-info__value {
      background: @c-warn;
    }
  }

  &.f-tag-info--normal {
    span {
      color: #fff;
    }
    .f-tag-info__label {
      background: #555;
    }
    .f-tag-info__value {
      background: @c-normal;
    }
  }

  &.f-tag-info--low {
    span {
      color: #fff;
    }
    .f-tag-info__label {
      background: #555;
    }
    .f-tag-info__value {
      background: @c-low;
    }
  }

  &.f-tag-info--strong {
    .f-tag-info__label {
      color: #fff;
      background: #555;
    }
    .f-tag-info__value {
      color: #333;
      background: #ffdb4b;
      font-weight: bold;
    }
  }

  &.f-tag-info--info {
    .f-tag-info__label {
      color: #fff;
      background: #555;
    }
    .f-tag-info__value {
      color: #333;
      background: lighten(@c, 37%);
    }
  }

  &.f-tag-info--deadly {
    .f-tag-info__label {
      color: #fff;
      background: black;
    }
    .f-tag-info__value {
      color: #fff;
      background: lighten(black, 37%);
    }
  }

  .f-tag-info__check {
    display: block;
    position: absolute;
    overflow: hidden;
    right: -8px;
    top: -6px;
    z-index: 5;
    @size: 16px;
    width: @size;
    height: @size;
    border-radius: 100%;
    background: lighten(@c, 25%);
    display: none;
    border: 1px solid transparent;
    text-align: center;
    line-height: 1;
    i {
      display: none;
      font-size: 12px;
      color: #fff;
      position: relative;
      line-height: 1;
    }
  }

  &.is-checkable {
    position: relative;
    & + .f-tag-info {
      margin: 0 0 0 10px;
    }
    .f-tag-info__value {
      position: relative;
      cursor: pointer;
      user-select: none;
      transition: 0.2s;
      border: 2px solid transparent;
      &:hover {
        background: lighten(@c, 32%);
      }
    }
    &.is-checked {
      .f-tag-info__value {
        // border-color: lighten(@c, 25%);
        background: @c;
        color: #fff;
      }
      .f-tag-info__check {
        display: block;
        background: #fff;
        border: 1px solid @c;
        i {
          color: @c;
          display: inline;
        }
      }
    }
  }
}
</style>
